package common;
import java.io.*;
public final class AllTheEvilsOfThisWorld {
	
	public static byte[] sendableToByteArray(Sendable s) throws Throwable {
		ByteArrayOutputStream b = new ByteArrayOutputStream();
		ObjectOutputStream oos = new ObjectOutputStream(b);
		oos.writeObject(s);
		return b.toByteArray();
	}
	public static Sendable byteArrayToSendable(byte [] b) throws Throwable {
		ByteArrayInputStream b2 = new ByteArrayInputStream(b);
		ObjectInputStream ois = new ObjectInputStream(b2);
		Object o = ois.readObject();
		return (o instanceof Sendable) ? (Sendable)o : null;
	}
	public static String obfuscateNumber( double price ) {
		return (price > 1e8) ? String.format("%.5e",price) : String.format("%.2f",price);
	}
	//What can I say? We needed to convert a string array to a string array.
	public static String [] stringArrayToStringArray (String [] iiiii) {
		int iii = 0;
		for (int i = -1,ii=0; i<iiiii.length; ii=iiiii[(++i<iiiii.length)?i:0].split(":")[0].length()) 
			if (ii>iii)iii=ii;
		for (int i = 0; i<iiiii.length; ++i) {
			String [] iiii = iiiii[i].split(":");
			iiii[0] = iiii[0] + "                             ".substring(0,iii-iiii[0].length()); 
			iiiii[i] = iiii[0]+":"+iiii[1]; 
		}
		return iiiii;
	}
}